package com.lagou.no4

import akka.actor.{Actor, ActorRef, ActorSystem, Props}

//向actor进行通信
class ActorA(aRef:ActorRef) extends Actor{
  //初始化通信次数
  var count = 0
  override def receive: Receive = {
    //当接收到发来的消息是start的时候打印信息
    case "start" => {
      println("ActorA 启动")
      println("stark,ok!")
      println("我打")
      //发给 BActor
      aRef ! "我打"
    } case "我打" => { //当接收到b发来的我打的时候，给count+1，打印输出并且发送消息
      count += 1
      println(s"ActorA(黄飞鸿) 挺猛 看我佛山无影脚 第${count}脚")
      Thread.sleep(1000)
      aRef ! "我打"
    }
  }
}

